//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    class Dog extends Animal{
        public void eat(){
            System.out.printLn("狗吃骨头");
        }
    }
    class Cat extends Animal{
        public void eat(){
            System.out.printLn("猫吃鱼");
        }
    }
    abstract class Animal{
        public abstract void eat();{

        }
    interface Afraid {
        void escape();

        void makeSounds

        void makeSounds();
    }

    static class Dog extends Animal implements Afraid {
        @Override
        public void escape() {
            System.out.printLn("狗害怕时逃跑");
        }

        public void makeSounds() {
            System.out.printLn("狗害怕时汪汪叫");
        }
    }

    class Cat extends Animal implements Afraid {
        @Override
        public void escape() {
            System.out.printLn("猫害怕时逃跑");
        }
        public void makeSounds() {
            System.out.printLn("猫害怕时喵喵叫");
        }
    }
    class Person {
        public void feed(Animal animal) {
            animal.eat();
        }

        public void catchAnimal(Afraid afraid) {
            afraid.escape();
            afraid.makeSounds();
        }
    }

    public class Main {
        public void main(String[] args) {
            Animal dog = new Dog();
            Animal cat = new Cat();
            Afraid dogAfraid = new Dog();
            Afraid catAfraid = new Cat();
            Person person = new Person();
            person.feed(dog);
            person.feed(cat);
            person.catchAnimal(dogAfraid);
            person.catchAnimal(catAfraid);
        }
    }
}